package o;

import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Binder;
import android.os.Bundle;
import android.os.RemoteException;
import androidx.annotation.NonNull;
import java.util.List;
import o.exu.b;

public class bpv extends b {
    private final Context ˋ;

    public bpv(@NonNull Context context) {
        this.ˋ = context;
    }

    public void ˊ(String str, List<Bundle> list, Bundle bundle, exq o_exq) throws RemoteException {
        if (o_exq == null) {
            boc.ˎ.ˊ("DynamicCoreStub", "callback must not be null.");
            return;
        }
        bps o_bos = new bos(o_exq);
        if (ˋ()) {
            Object obj = (ˏ(str, bundle, (List) list, o_bos) && ˊ(str, o_bos)) ? 1 : null;
            if (obj != null) {
                bqf ˊ = bqf.ˊ(list);
                if (ˊ.ˋ().isEmpty()) {
                    o_bos.ॱ(2, "modules must not be null or empty.");
                    return;
                }
                switch (bpu.ˎ(bundle).ˎ()) {
                    case 1:
                        new bpa(this.ˋ, o_bos).ˋ(str, ˊ);
                        return;
                    default:
                        o_bos.ॱ(4, "invalid api-version.");
                        return;
                }
            }
            return;
        }
        o_bos.ॱ(8, "No silent install permission.");
    }

    public void ˎ(String str, int i, Bundle bundle, exq o_exq) throws RemoteException {
        if (o_exq == null) {
            boc.ˎ.ˊ("DynamicCoreStub", "callback must not be null.");
            return;
        }
        bpr o_boo = new boo(o_exq);
        if (ˋ()) {
            Object obj = (ॱ(str, bundle, o_boo) && ˊ(str, o_boo)) ? 1 : null;
            if (obj != null) {
                switch (bpu.ˎ(bundle).ˎ()) {
                    case 1:
                        new bov(this.ˋ, o_boo).ˏ(str, i);
                        return;
                    default:
                        o_boo.ॱ(4, "invalid api-version.");
                        return;
                }
            }
            return;
        }
        o_boo.ॱ(8, "No silent install permission.");
    }

    public void ˎ(String str, List<Bundle> list, Bundle bundle, exq o_exq) throws RemoteException {
        if (o_exq == null) {
            boc.ˎ.ˊ("DynamicCoreStub", "callback must not be null.");
            return;
        }
        bps o_boq = new boq(o_exq);
        if (ˋ()) {
            Object obj = (ˏ(str, bundle, (List) list, o_boq) && ˊ(str, o_boq)) ? 1 : null;
            if (obj != null) {
                bqf ˊ = bqf.ˊ(list);
                if (ˊ.ˋ().isEmpty()) {
                    o_boq.ॱ(2, "modules must not be null or empty.");
                    return;
                }
                switch (bpu.ˎ(bundle).ˎ()) {
                    case 1:
                        new bot(this.ˋ, o_boq).ˎ(str, ˊ);
                        return;
                    default:
                        o_boq.ॱ(4, "invalid api-version.");
                        return;
                }
            }
            return;
        }
        o_boq.ॱ(8, "No silent install permission.");
    }

    public void ˏ(String str, List<Bundle> list, Bundle bundle, exq o_exq) throws RemoteException {
        if (o_exq == null) {
            boc.ˎ.ˊ("DynamicCoreStub", "callback must not be null.");
            return;
        }
        bps o_bop = new bop(o_exq);
        if (ˋ()) {
            Object obj = (ˏ(str, bundle, (List) list, o_bop) && ˊ(str, o_bop)) ? 1 : null;
            if (obj != null) {
                bqf ˊ = bqf.ˊ(list);
                if (ˊ.ˋ().isEmpty()) {
                    o_bop.ॱ(2, "modules must not be null or empty.");
                    return;
                }
                switch (bpu.ˎ(bundle).ˎ()) {
                    case 1:
                        new bow(this.ˋ, o_bop).ˎ(str, ˊ);
                        return;
                    default:
                        o_bop.ॱ(4, "invalid api-version.");
                        return;
                }
            }
            return;
        }
        o_bop.ॱ(8, "No silent install permission.");
    }

    public void ॱ(String str, int i, Bundle bundle, exq o_exq) throws RemoteException {
        if (o_exq == null) {
            boc.ˎ.ˊ("DynamicCoreStub", "callback must not be null.");
            return;
        }
        bpw o_bon = new bon(o_exq);
        if (ˋ()) {
            Object obj = (ॱ(str, bundle, o_bon) && ˊ(str, o_bon)) ? 1 : null;
            if (obj != null) {
                switch (bpu.ˎ(bundle).ˎ()) {
                    case 1:
                        new box(this.ˋ, o_bon).ˎ(str, i);
                        return;
                    default:
                        o_bon.ॱ(4, "invalid api-version.");
                        return;
                }
            }
            return;
        }
        o_bon.ॱ(8, "No silent install permission.");
    }

    public void ˏ(String str, Bundle bundle, exq o_exq) throws RemoteException {
        if (o_exq == null) {
            boc.ˎ.ˊ("DynamicCoreStub", "callback must not be null.");
            return;
        }
        bpy o_bou = new bou(o_exq);
        if (ˋ()) {
            Object obj = (ॱ(str, bundle, o_bou) && ˊ(str, o_bou)) ? 1 : null;
            if (obj != null) {
                switch (bpu.ˎ(bundle).ˎ()) {
                    case 1:
                        new boz(this.ˋ, o_bou).ˊ(str);
                        return;
                    default:
                        o_bou.ॱ(4, "invalid api-version.");
                        return;
                }
            }
            return;
        }
        o_bou.ॱ(8, "No silent install permission.");
    }

    private boolean ˏ(String str, Bundle bundle, List<Bundle> list, @NonNull bps o_bps) {
        if (!ॱ(str, bundle, o_bps)) {
            return false;
        }
        if (list != null && !list.isEmpty()) {
            return true;
        }
        o_bps.ॱ(2, "modules must not be null or empty.");
        return false;
    }

    private boolean ॱ(String str, Bundle bundle, @NonNull bps o_bps) {
        if (str == null || str.isEmpty()) {
            o_bps.ॱ(2, "pkgName must not be null or empty.");
            return false;
        } else if (bundle != null) {
            return true;
        } else {
            o_bps.ॱ(2, "extraInfo must not be null.");
            return false;
        }
    }

    private boolean ˊ(@NonNull String str, @NonNull bps o_bps) {
        if (ॱ(str) && ˎ(str)) {
            return true;
        }
        o_bps.ॱ(3, "pkgName is invalid.");
        return false;
    }

    private boolean ॱ(@NonNull String str) {
        String[] packagesForUid = this.ˋ.getPackageManager().getPackagesForUid(Binder.getCallingUid());
        if (packagesForUid == null) {
            return false;
        }
        for (Object equals : packagesForUid) {
            if (str.equals(equals)) {
                return true;
            }
        }
        return false;
    }

    private boolean ˎ(@NonNull String str) {
        try {
            this.ˋ.getPackageManager().getPackageInfo(str, 0);
            return true;
        } catch (NameNotFoundException e) {
            return false;
        }
    }

    private boolean ˋ() {
        return bpn.ˋ();
    }
}
